package com.study.agp.binding;

import android.widget.ImageView;
import androidx.databinding.BindingAdapter;

public class MyImageBindingAdapter {

    @BindingAdapter("default_image")
    public static void setDefaultImage(ImageView view, int resId) {
        view.setImageResource(resId);
    }

    @BindingAdapter("default_url")
    public static void setDefaultUrl(ImageView view, String url) {
        // 支持方法重载
        System.out.println("default_url: url: " + url);
    }

    @BindingAdapter(value = {"default_image", "default_url"}, requireAll = true)
    public static void setDefaultImageUrl(ImageView view, int resId, String url) {
        // 支持方法重载
        setDefaultImage(view, resId);
        setDefaultUrl(view, url);
    }
}
